<!DOCTYPE html>
<html>
<head>
{include file="common/head"}
<style type="text/css">
.layui-form-module .layui-form-label {
    float: none;
    width: auto;
    text-align: left;
    padding: 9px 0px;
}
.layui-form-module .layui-input-block, .layui-form-module .layui-input-inline{
    margin-left: 0px;
}
</style>
</head>
{include file="common/header"}
<body style="background-color: #f2f2f2;">
<div class="layui-container" style="margin-top: 80px;">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
    
      <div class="layui-card">
        <div class="layui-card-header">发布文章</div>
        <div class="layui-card-body">
      <form class="layui-form layui-form-module" action="{:url('wendasns/article/post')}" method="post">
        <input type="hidden" name="id" value="{$article.id}">
        
        <div class="layui-form-item">
          <label class="layui-form-label">标题</label>
          <div class="layui-input-block">
            <input type="text" name="title" autocomplete="off" class="layui-input" value="{$article.title}">
          </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">摘要</label>
          <div class="layui-input-block">
            <textarea name="summary" class="layui-textarea">{$article.summary}</textarea>
          </div>
        </div>
        
        <div class="layui-form-item">
          <label class="layui-form-label">内容</label>
          <div class="layui-input-block">
            <textarea id="article-text" name="content" style="display: none;" lay-verify="content" data-id="">{$article.content}</textarea>
          </div>
          
        </div>
        
        <div class="layui-form-item">
          <label class="layui-form-label">分类</label>
          <div class="layui-input-inline">
            <select name="category">
            {volist name="category" id="item"}
              <option value="{$item.id}"{if isset($article) && $article.category_id eq $item.id} selected{/if}>{$item.name}</option>
            {/volist}
            </select>
          </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">标签</label>
          <div class="layui-input-inline">
            <input type="text" name="tags" class="layui-input" value="{$article.tags}">
          </div>
          <div class="layui-form-mid layui-word-aux">多个标签用英文逗号，或空格隔开</div>
        </div>
        
        <div class="layui-form-item">
          <label class="layui-form-label">允许评论</label>
          <div class="layui-input-block">
            <input type="radio" name="speak" title="是" value="1" {if isset($article.speak)}{$article.speak==1?'checked':''}{else}checked{/if}>
            <input type="radio" name="speak" title="否" value="0" {if isset($article.speak) and $article.speak eq 0}checked{/if}>
          </div>
        </div>

        <div class="layui-form-item">
          <div class="layui-input-block">
              <button class="layui-btn" lay-submit="" lay-filter="J_ajax_submit_btn">提交</button>
          </div>
        </div>
        
          </form>
        </div>
      </div>
      
    </div>
    
  </div>
</div>
{include file="common/footer"}
<script src="/ueditor/ueditor.init.js?v={:time()}"></script>
<script>
;!function(){

  var $ = layui.$
  ,layedit = layui.layedit
  ,form = layui.form;
  
	layedit.set({
	  uploadImage: {
	    url: '{:url('wendasns/common/upload',['type'=>'article'])}'
	  },
	  height: 500
	});

	var index = layedit.build('article-text');
	$('#article-text').attr('data-id',index);

  form.render();
  
  form.verify({
    title: function(value){
      if(value.length > 49){
        return '标题最多49个字符';
      }
    }
  });
  
}();
</script>
</body>
</html>